import { NavBar, Icon } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import PropTypes from "prop-types";
function NavHeader({ title, right, onLeftClick }) {
  // 添加props校验
  const navigate = useNavigate();
  const defaultClick = () => {
    navigate(-1);
  };
  return (
    <NavBar
      mode="light"
      icon={<Icon type="left" size="md" />}
      onLeftClick={onLeftClick || defaultClick}
      rightContent={right}
    >
      <div style={{ fontSize: "14px" }}> {title}</div>
    </NavBar>
  );
}
// 添加校验
NavHeader.propTypes = {
  title: PropTypes.string.isRequired,
  onLeftClick: PropTypes.func,
};
export default NavHeader;
